function addImage(filename,id,albumdir,w,h)
{
    var images = $('#images');
    var tpl = '<div id="'+id+'" class="image" style="width: '+(w+4)+'px; height: '+(h+23)+'px;" ><a href="/images/delete/?i='+filename+'" class="imgdelete" title="Delete image" onClick="deleteImage('+"'"+filename+"'"+','+"'"+id+"'"+'); return false;">X</a><a href="/'+albumdir+filename+'" class="imgwarper" style="width: '+w+'px; height: '+(h+1)+'px;"><img src="/images/thumb?i='+filename+'" alt="'+filename+'" style=" width:'+w+'px; heigth:'+w+';"/></a></div>'+"\n";
    images.html(tpl+images.html());
    rebilupload();
    rebildIfame();
}

function uploadError()
{
    alert('File upload error.');
    rebildIfame();
}

function rebildIfame()
{
    $("#upload_frame").attr("src","about:blank");
}

function deleteImage(img,id)
{
    $.ajax({
        type: "GET",
        url: "/images/delete/",
        data: "i="+img+"&ajax=true",
        success: function(msg){
              
              $('#'+id).animate({
               opacity: 0.0
               }, 300,function () {
                $('#'+id).remove();
               });
        }
    });
}

function deleteAll()
{
    $.ajax({
        type: "GET",
        url: "/images/deleteall/",
        data: "ajax=true",
         success: function(msg){
            $("#images > div").animate({
               opacity: 0.0
               }, 500,function () {
                $("#images > div").remove();
               });
        }
    });
}

